merge_student_expenditure<-function(){
  data_expenditure_purchases<-data_expenditure[[1]] %>% 
    filter(ValoareRON<500000) %>%
    group_by(an,judet.bac,unitate_de_invatamant) %>%
    summarise(Expenditure=sum(ValoareEUR))
  
  data_expenditure_contracts<-data_expenditure[[2]] %>%
    group_by(an,judet.bac,unitate_de_invatamant) %>%
    summarise(Expenditure=sum(ValoareEUR))
  
  data_expenditure_complete<-rbind(data_expenditure_purchases,data_expenditure_purchases, .id='expenditure_source') %>%
    mutate(expenditure_source=ifelse(expenditure_source==1,'purchases',expenditure_source)) %>% 
    mutate(expenditure_source=ifelse(expenditure_source==2,'contracts',expenditure_source)) %>%
    group_by(an,judet.bac,unitate_de_invatamant) %>%
    summarise(Expenditure=sum(Expenditure))
    
  data_student_expenditure<-base::merge(data_student,data_expenditure_complete,by.x=c("judet_bac","unitate_de_invatamant","an"),by.y=c("judet.bac","unitate_de_invatamant","an"))
  
  #stats<-data_student_teacher_expenditure %>% group_by(an,n_hs_town_group) %>% summarize(n=n())
  #stats<-data_student_teacher %>% group_by(an,n_hs_town_group) %>% summarize(n=n())
  
  setwd(wd_data_final)
  saveRDS(data_student_expenditure,"data_student_expenditure")
  return(data_student_expenditure)
}